package com.et.machine.manager.view

import android.content.Context
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.util.AttributeSet
import android.view.View

open class ViewGoodsStatus : View {

    constructor(context: Context?) : this(context, null)

    constructor(
        context: Context?,
        attrs: AttributeSet? = null,
    ) : this(context, attrs, 0)

    constructor(
        context: Context?,
        attrs: AttributeSet? = null,
        defStyleAttr: Int = 0,
    ) : super(context, attrs, defStyleAttr)


    private var viewWidth: Int = 0
    private var viewHeight: Int = 0
    private val paint: Paint = Paint().apply {
        color = Color.BLACK
    }

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
        viewWidth = width
        viewHeight = height
    }

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        canvas?.let {
            it.drawCircle(width / 2f, height / 2f, width / 2f, paint)
        }
    }
}